Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements and bug fixes for sizeof calculator #236

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Mingun
Copy link
Contributor

@Mingun Mingun commented Dec 5, 2021

This PR improves situation with _sizeof / sizeof<>:

  • switch-on types with the same size in all arms now correctly have the constant size
  • if keys now correctly influence to class / attribute sizeof (fixes _sizeof special property does not properly handle conditional fields kaitai_struct#927)
  • as a side effect, improvements in the constant evaluator of boolean values
  • add tests for boolean constant evaluator
  • add tests for sizeof calculator
  • forbid explicit negative repetition number in the repeat-expr key
  • forbid explicit repeat-until: <falsy value> because that will lead to an infinity cycle

This PR is based on the #225 because the last commit (f6238c0) from that PR is needed for correct switch-on size calculations

Also this PR fixes the expr_sizeof_value_dynamic3.ksy test -- corresponding PR to the tests repository: kaitai-io/kaitai_struct_tests#95. Also, this test was mentioned in the kaitai-io/kaitai_struct#721

@Mingun
Copy link
Contributor Author

Mingun commented Jun 24, 2022

@generalmimon , I see that you've started to merge some PRs and close issues. Could you look at my PRs? This one is a good candidate to start. List of all my PRs: https://github.com/pulls?page=1&q=is%3Aopen+is%3Apr+author%3AMingun+archived%3Afalse+org%3Akaitai-io

Mingun added a commit to Mingun/kaitai_struct_tests that referenced this pull request Apr 10, 2023
@Mingun Mingun force-pushed the sizeof-tests branch 9 times, most recently from bba5067 to b1bc207 Compare September 12, 2023 16:57
@Mingun Mingun force-pushed the sizeof-tests branch 2 times, most recently from bb40c22 to d00f859 Compare October 24, 2023 15:29
@Mingun
Copy link
Contributor Author

Mingun commented Mar 7, 2024

@GreyCat, @generalmimon, I see that you have some activity in the project recently. Could you find a time to review my PRs, for example, this?

@Mingun Mingun force-pushed the sizeof-tests branch 3 times, most recently from 1e3c413 to 4346a1f Compare March 8, 2024 13:49
Mingun added a commit to Mingun/kaitai_struct_tests that referenced this pull request Mar 8, 2024
Mingun added a commit to Mingun/kaitai_struct_tests that referenced this pull request Jul 16, 2024
@Mingun Mingun force-pushed the sizeof-tests branch 2 times, most recently from d972411 to c33618e Compare July 16, 2024 14:49
@Mingun Mingun force-pushed the sizeof-tests branch 4 times, most recently from ff2df58 to ee12aec Compare September 8, 2024 10:12
Mingun added 9 commits October 4, 2024 22:42
Part of them already was sealed, so there is no reasons to not seal other
Both ArrayTypeInStream and CalcArrayType the only existing successors
of the sealed class TypeDetector so we can do that simplification
Fow now only very basic tests is implemented - only size of built-in types is tested
The following tests failed before the change:

[info] Ast$Test:
[info] - considers `false and ?` constant *** FAILED ***
[info]   None was not equal to Some(false) (Ast$Test.scala:67)
[info] - considers `? and false` constant *** FAILED ***
[info]   None was not equal to Some(false) (Ast$Test.scala:74)
[info] - considers `true or ?` constant *** FAILED ***
[info]   None was not equal to Some(true) (Ast$Test.scala:81)
[info] - considers `? or true` constant *** FAILED ***
[info]   None was not equal to Some(true) (Ast$Test.scala:88)
- Forbid negative counts of repetitions in `repeat-expr`
- Warn about zero counts in `repeat-expr`
- Forbid falsy values in `repeat-until`
- Warn about only one iteration in `repeat-until`
Mingun added a commit to Mingun/kaitai_struct_tests that referenced this pull request Oct 6, 2024
@Mingun
Copy link
Contributor Author

Mingun commented Oct 6, 2024

@generalmimon, @GreyCat, there already almost 3 years past. Could you look at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

_sizeof special property does not properly handle conditional fields
1 participant